﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadProps.Testability
{
    public class PropChangeRecorder
    {
        public void Subscribe(IPropChangedRaiser raiser)
        {
            raiser.PropChanged += raiser_PropChanged;
        }

        List<PropChangedEventArgs> changes = new List<PropChangedEventArgs>();

        void raiser_PropChanged(object sender, PropChangedEventArgs e)
        {
            changes.Add(e);
        }

        public int ChangeCountFor(params IHavePropId[] props)
        {
            return changes.Where(c => c.Prop.IsAny(props)).Count();
        }

        public int Total { get { return changes.Count; } }

        public void Reset()
        {
            changes.Clear();
        }
    }
}
